package tests;

import static org.junit.Assert.*;

import model.Role;
import model.User;

import org.junit.Before;
import org.junit.Test;

/**
 * Tests the User class for user equality. Users are considered equal if their
 * emails are the same.
 * 
 * @author Ahmed Abdul-Rahman (aabdulr@gmail.com)
 * @version Winter 2012.
 * 
 * 
 */
public class UserTest {

  private User my_user_one;

  private User my_user_two;

  private User my_user_three;

  /**
   * Initializes test objects.
   */
  @Before
  public void setUp() {
    my_user_one = new User("Ahmed", "aabdulr@gmail.com", Role.STAFF_MEMBER);
    my_user_two = new User("James", "aabdulr@gmail.com", Role.VOLUNTEER);
    my_user_three = new User("Ben", "jmgunter@gmail.com", Role.PARK_MANAGER);
  }

  @Test
  public void test() {

    // USING THE DEFINED EQUALS METHOD.

    // Test USERONE against USERTWO, if same, it returns true and passes.
    assertTrue(my_user_one.equals(my_user_two));

    // Test USERONE against USERThree, should return false as they are not same.
    assertFalse(my_user_one.equals(my_user_three));

    // Test userOne against UserOne, if they are same, it returns true.
    assertTrue(my_user_one.equals(my_user_one));

    // USING JUnit's ASSERT EQUALS METHOD

    // Testing userOne against userTwo
    assertEquals(my_user_one, my_user_two);

  }

}
